package gui.commands.classDiagramCommands;

import data.DataVector;
import data.classDiagram.Entity;
import gui.commands.ICommand;

/**
 * User: Szymon Kudzia
 * Date: 10.05.13
 * Time: 15:38
 */
public class DeleteEntityCommand implements ICommand {
	protected Entity entity;

	public DeleteEntityCommand(Entity entity) {
		this.entity = entity;
	}

	@Override
	public void execute() {
		DataVector.getInstance().removeEntity(entity);
		refresh();
	}

	@Override
	public void undo() {
		DataVector.getInstance().addEntity(entity);
		refresh();
	}

	@Override
	public void redo() {
		DataVector.getInstance().removeEntity(entity);
		refresh();
	}

	private void refresh() {
		DataVector.getInstance().refresh();
	}
}
